//
//  ViewController.m
//  11203
//
//  Created by student on 16/3/3.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.teams = [[NSArray alloc] initWithObjects:@"A1-南非",@"A2-墨西哥",
     @"B1-阿根廷",@"B2-尼日利亚",@"C1-英格兰",@"C2-美国",
     @"D1-德国",@"D2-澳大利亚",@"E1-荷兰",@"E2-丹麦",
     @"G1-巴西",@"G2-朝鲜",@"H1-西班牙",@"H2-瑞士",nil];
    
    self.pics= [[NSArray alloc] initWithObjects:@"SouthAfrica.png",@"Mexico.png",
     @"Argentina.png",@"Nigeria.png",@"England.png",@"USA.png",
     @"Germany.png",@"Australia.png",@"Holland.png",@"Denmark.png",                      @"Brazil.png",@"NorthKorea.png",@"Spain.png",@"Switzerland.png",nil];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.teams.count;
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
//    @property (nonatomic, readonly, strong, nullable) UIImageView *imageView NS_AVAILABLE_IOS(3_0);   // default is nil.  image view will be created if necessary.
//    
//    @property (nonatomic, readonly, strong, nullable) UILabel *textLabel NS_AVAILABLE_IOS(3_0);   // default is nil.  label will be created if necessary.
//    @property (nonatomic, readonly, strong, nullable) UILabel *detailTextLabel NS_AVAILABLE_IOS(3_0); // default is nil.  label will be created if necessary (and the current style supports a detail label).
    cell.imageView.image = [UIImage imageNamed:self.pics[indexPath.row]];
    cell.textLabel.text = self.teams[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *result = [NSString stringWithFormat:@"你选择了%@",self.teams[indexPath.row]];
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"选择结果" message:result delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
    [alert show];
}
@end
